<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .main {
            width: 1226px;
            height: 460px;
            margin: 50px auto;
            position: relative;
        }

        .picture {
            width: 1226px;
            height: 460px;
            list-style: none;
        }

        .picture li {
            width: 1226px;
            height: 460px;
            display: none;
        }

        .picture>.show {
            display: block;
        }

        .picture img {
            width: 100%;
            height: 100%;
        }

        .left {
            width: 60px;
            height: 120px;
            line-height: 120px;
            text-align: center;
            position: absolute;
            left: 0;
            top: 170px;
        }

        .right {
            width: 60px;
            height: 120px;
            line-height: 120px;
            text-align: center;
            position: absolute;
            right: 0;
            top: 170px;
        }

        .buttom {
            width: 100px;
            height: 40px;
            list-style: none;
            position: absolute;
            right: 20px;
            bottom: 20px;
            display: flex;
            justify-content: space-around;
            align-items: center;
        }

        .buttom li {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            border: 1px solid black;
            background-color: #222;
        }

        .buttom>.active {
            background-color: #eee;
        }
    </style>
</head>

<body  onselectstart="return false">
    <div class="main">
        <ul class="picture">
            <li class="show">
                <a href="">
                    <img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/78d5371a86f61bc443457b09b7a2d508.jpg?w=2452&h=920"
                        alt="">
                </a>
            </li>
            <li>
                <a href="">
                    <img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/7c2b5d308761d257483badf0bc4eca22.jpg?thumb=1&w=1533&h=575&f=webp&q=90"
                        alt="">
                </a>
            </li>
            <li>
                <a href="">
                    <img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/100ccd8be5b6a85a81759a6ad2953083.jpg?thumb=1&w=1533&h=575&f=webp&q=90"
                        alt="">
                </a>
            </li>
            <li>
                <a href="">
                    <img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/918820682e4a490221cfd92b24c14b86.jpg?thumb=1&w=1533&h=575&f=webp&q=90"
                        alt="">
                </a>
            </li>
            <li>
                <a href="">
                    <img src="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/11829e973197010c1f012f70aafde8f4.jpg?thumb=1&w=1533&h=575&f=webp&q=90"
                        alt="">
                </a>
            </li>
        </ul>
        <div class="left">左</div>
        <div class="right">右</div>
        <ul class="buttom">
            <li class="active"></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
</body>
<script>
    var main = document.querySelector(".main");
    var pictureLi = document.querySelectorAll(".picture li");
    var buttomLi = document.querySelectorAll(".buttom li");
    var left = document.getElementsByClassName("left")[0];
    var right = document.getElementsByClassName("right")[0];

    var index = 0;
    for (let i = 0; i < buttomLi.length; i++) {
        let li = buttomLi[i];
        li.onclick = function () {
            index = i;
            for (var j = 0; j < buttomLi.length; j++) {
                buttomLi[j].className = "";
                pictureLi[j].className = "";
            }
            buttomLi[i].className = "active";
            pictureLi[i].className = "show";
        }
    }

    //轮播
    var timer = setInterval(suffling, 2000);
    function suffling() {
        if (index < buttomLi.length - 1) {
            index++;
        }else{
            index = 0;
        }
        for (var j = 0; j < buttomLi.length; j++) {
            buttomLi[j].className = "";
            pictureLi[j].className = "";
        }
        buttomLi[index].className = "active";
        pictureLi[index].className = "show";
    }

    //点击右实现换图
    var delay = null;
    right.onclick = function(){
        clearTimeout(delay);
        clearInterval(timer);
        suffling();

        delay = setTimeout(function(){
            timer = setInterval(suffling, 2000);
        } , 4000);
    }

    // 鼠标移入 暂停
    main.onmouseover = function(){
        clearInterval(timer);
    }

    // 鼠标移出 启动
    main.onmouseout = function(){
        timer = setInterval(suffling, 2000);
    }
</script>

</html>